package com.ry.novel.service.impl;

import com.ry.novel.enums.NovelConst;
import com.ry.novel.mapper.ReportMapper;
import com.ry.novel.model.dto.ReportInfo;
import com.ry.novel.model.entity.Report;
import com.ry.novel.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author ry
 * @since 2022-04-19 21:59
 **/
@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportMapper reportMapper;

    @Override
    public void addReport(ReportInfo info) {
        Report report = new Report();
        report.setUserId(info.getUserId());
        report.setBookId(info.getBookId());
        report.setBookIndexId(info.getBookIndexId());
        report.setContent(info.getContent());
        report.setCreateTime(LocalDateTime.now().toString());
        report.setState(NovelConst.REPORT_NOT_HANDLE);

        reportMapper.insert(report);
    }
}
